<?php

//Latest Seyret Module v.0.2//

/**

* Content code

* @package Latest Seyret

* @Copyright (C) 2007 Mustafa DINDAR

* @ ToolTip MouseOvers added by Larry Gillock Jr. at JoomlaToys.com

* @ All rights reserved

* @ latest seyret module is Free Software

* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html

* @version 0.2

**/	



// no direct access

defined( '_VALID_MOS' ) or die( 'Restricted access' );



global $database, $mosConfig_live_site, $mosConfig_absolute_path, $mainframe;





$videocount 		= $params->get( 'count' );

$catid  			= $params->get('catid','');

$order				= $params->get('order','title');

$showtitles 		= $params->get( 'showtitles' );

$videothumbwidth 	= $params->get( 'videothumbwidth' );

$videothumbheight 	= $params->get( 'videothumbheight' );

$showsubmitter 		= $params->get( 'showsubmitter' );

$showaddeddate  	= $params->get( 'showaddeddate' );

$showdescription    = $params->get( 'showdescription' );

$showcolumn    		= $params->get( 'showcolumn',4 );

	echo '<link rel="stylesheet" href="'.$mosConfig_live_site.'/modules/mod_featured_seyret_hor/style.css" type="text/css"  />';


	$i=0;
	
	
	if($catid != ''){
	  $query =  "SELECT * FROM #__seyret_items as i, #__seyret_categories as c WHERE c.id IN (".$catid.") AND i.catid = c.catid AND i.published='1' AND i.featured='1'";
	  $orderby = " ORDER BY i." . $order . " DESC";
	  $query .= $orderby . " LIMIT 0, $videocount"; 
	}else{
		$query =  "SELECT * FROM #__seyret_items WHERE published='1' AND featured='1' ORDER BY ". $order ." DESC LIMIT 0, $videocount";
	}
	
	
	$database->setQuery( $query );
	
	$vidyo = $database->loadObjectList();
	//print_r( $vidyo); die; 
	$num= count($vidyo);

		echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" style=\"text-align:center;\">";

		foreach ($vidyo as $vidyo) {

		$i++;

		$vid=$vidyo->id;

		$vhit=$vidyo->hit;

		$vtitle=$vidyo->title;

		$vdescription = $vidyo->itemcomment ;

		$vpicturelink = $vidyo->picturelink;

		$votes=$vidyo->voteclick;

		$vratingtotal=$vidyo->votetotal;

		$vaddedby=$vidyo->addedby;

		$vaddedbyname=jaseyret_featuredvideomodulehorgetusersname($vaddedby);

		$vaddeddate=$vidyo->addeddate;

		$link=$mosConfig_live_site."/index.php?option=com_seyret&task=videodirectlink&id=".$vid;

		

		if ($vpicturelink==""){

$vpicturelink=$mosConfig_live_site."/components/com_seyret/localplayer/nothumbnail.png";

		}

			if($i==1 || ($i-1)%$showcolumn ==0){

				if( ($i-1)%$showcolumn ==0 ){

					echo "<tr><td colspan='$showcolumn' height='15'></td></tr>";

				}

				echo "<tr>";

			}

			echo "<td>";		

			$tags= "<div class='seyret-b' ";

			if( ($i==1)|| ($i-1)%$showcolumn ==0 ){

				$tags .= "style='margin-right:15px;' >";

			}else if( ($i)%$showcolumn ==0 ){

				$tags .= "style='margin-left:15px;' >";			

			}else{

				$tags .= "style='margin:0 15px;' >";

			}

			

			$tags .= "<div class='seyret-l'><div class='seyret-r'><div class='seyret-t'>";

			echo $tags;

			echo "<div class='seyret-tl'><div class='seyret-tr'><div class='seyret-bl'><div class='seyret-br'>";

			

			echo "<a href=".SefRelToAbs($link)."><img src=\"".$vpicturelink."\" width=\"".$videothumbwidth."\" height=\"".$videothumbheight."\" alt=\"".$vtitle."\" /></a><br>";

			if ($showtitles=="1") {

			echo "<br/><a href=".$link." class='seyret_title'>".$vtitle."</a><br>";

			}

			

			echo "<p class='seyret_content'>";

			if ($showdescription=="1") {

			echo $vdescription."<br>";

			}



			if ($showsubmitter=="1") {

			echo $vaddedbyname."<br>";

			}



			if ($showaddeddate=="1") {

			echo $vaddeddate."<br>";

			}

			echo "</p>";



			echo "</div></div></div></div>";

			echo "</div></div></div></div>";

			echo "</td>";

			if( (($i-1)%$showcolumn)==0 && $i==$num){

				echo "</tr>";

			}

			

		}
		echo "</table>";
		echo "<div style='position:absolute;top:-9999px;'> development by <a href='http://www.joommaster.com'>joommaster team.</a></div>";




function jaseyret_featuredvideomodulehorgetusersname($id) {

global $database, $my;



		$database->setQuery("SELECT name FROM #__users WHERE id='$id'"); 		

		$usname = $database->loadObjectList();

		foreach ($usname as $usname) 

		{

		$username=$usname->name;

		}

	

	return $username;

}	

?>